package com.gem.talkbase.adapter;



import java.util.List;
import net.tsz.afinal.FinalBitmap;
import com.gem.talkbase.R;
import com.gem.talkbase.bean.FirendRing;
import com.gem.talkbase.util.TimeRender;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;



 public  class FirendRingAdapter extends BaseAdapter {
	 
 
		private Context context;
		String username,userimage,date;
		private List<FirendRing> msgs = null;
		FinalBitmap fb;
		public  FirendRingAdapter(Context context, List<FirendRing> listItem,String username,String userimage,String date) {
			super();
			this.context = context;
			this.msgs = listItem;
			this.username=username;
			this.userimage=userimage;
			this.date=date;
			System.out.println(username+"============"+userimage+"============="+listItem.size());
		}
		@Override
		public int getCount() {
			return msgs.size();
		}
		@Override
		public Object getItem(int position) {
			return msgs.get(position);
		}
		@Override
		public long getItemId(int position) {
			return position;
		}
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			FirendRing firendRing = (FirendRing) msgs.get(position);
			System.out.println("=================================11111111111111111111111111");
			ViewHolder holder=new ViewHolder();
			fb=FinalBitmap.create(context);
			if(position ==0){		
				holder.flag = position;
				convertView = LayoutInflater.from(context).inflate(R.layout.mixed_feed_cover_row,null);
				ImageView cover = (ImageView) convertView.findViewById(R.id.show_background);
				cover.setImageResource(R.drawable.beijing);
				ImageView head_picture = (ImageView) convertView.findViewById(R.id.head_picture);
				fb.display(head_picture, userimage);	
				TextView unickTextView=(TextView)convertView.findViewById(R.id.unick_tv1);
				unickTextView.setText(username);
				
			}else {
				System.out.println("==============================================");
				convertView = LayoutInflater.from(context).inflate(R.layout.mixed_feed_activity_item, null);
				ImageView authorView = (ImageView) convertView.findViewById(R.id.mixed_feed_author_photo);
				//authorView.setImageResource(message.getAuthorAvatar());
				//authorView.setScaleType(ScaleType.FIT_XY);
				System.out.println(firendRing.getPhotoname()+"==============firendRing.getPhotoname()");
				
				fb.display(authorView, firendRing.getUserimage());
			  
				TextView authorName = (TextView) convertView.findViewById(R.id.haoyou1);
				authorName.setText(firendRing.getUser_id());
				System.out.println(firendRing.getUser_id()+"==============firendRing.getUser_id()");
				
				TextView time = (TextView) convertView.findViewById(R.id.set_time_text);
				time.setText(TimeRender.getDate());
				System.out.println(firendRing.get_time()+"==============firendRing.get_time()");
				
				TextView shuoshuo = (TextView) convertView.findViewById(R.id.shuoshuo);
				shuoshuo.setText(firendRing.getEdit());
				
				System.out.println(firendRing.getEdit()+"==============firendRing.getEdit()");
				
				ImageView set_time_picture = (ImageView) convertView.findViewById(R.id.set_time_picture);
//				fb.configBitmapMaxHeight(260);
//				fb.configBitmapMaxWidth(260);
				fb.display(set_time_picture, firendRing.getPhotoname());
			}

			return convertView;
		}
		static class ViewHolder {
			TextView text;
			TextView time;
			TextView status;
			int flag = -1;
		}


}

